package com.mezz.bones.im.common.enums;

import com.mezz.bones.im.common.exception.ImBaseException;
import com.mezz.bones.im.common.result.ImResultCode;

/**
 * @Author: zhuang
 * @Date: 2024/12/6 17:29
 * @Description: IM会话 客服类型
 * @Version: 1.0
 **/

public enum RelationTypeEnum {
    NONE(-1, "非客服会话"),
    MAIN(1, "母号(供应商母号-供应商ID 平台母号-默认0) 客服→用户"),
    SUB(0, "子号(供应商子号-供应商客服ID 平台子号-平台客服ID) 用户→客服");

    private final Integer code;
    private final String text;

    RelationTypeEnum(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public Integer getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public static RelationTypeEnum findEnum(Integer code){

        for (RelationTypeEnum value : RelationTypeEnum.values()) {

            if (value.getCode().equals(code)) {
                return value;
            }
        }

        throw new ImBaseException(ImResultCode.DATA_NOT_FOUND,"RelationTypeEnum枚举不存在: " + code);
    }

}